/*
 *  Copyright 2020-2025 the original author or authors.
 *  You cannot use this file unless authorized by the author.
 */

package org.ipig.computing.spark.conf;

import lombok.Data;
import lombok.ToString;
import org.apache.commons.beanutils.BeanUtils;
import org.ipig.commons.conf.ConfService;
import org.ipig.commons.conf.kafka.consumer.KafkaConsumerConf;
import org.ipig.commons.conf.kafka.producer.KafkaProducerConf;
import org.ipig.commons.conf.mongo.MongoConf;
import org.ipig.commons.conf.redis.RedisConf;
import org.ipig.commons.conf.spike.SpikeConf;
import org.ipig.model.proc.FlowRequesterConf;

import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;

/**
 * SparkExecutorConf
 *
 * @author <a href="mailto:comchnts@163.com">chinats</a>
 * @since 1.0
 */
@Data
@ToString
public class SparkExecutorConf extends SparkLauncherConf implements Serializable, ConfService, Cloneable {
    //mongo配置
    private SparkMongoConf<MongoConf, MongoConf> sparkMongoConf;
    //spike配置
    private SparkSpikeConf<SpikeConf, SpikeConf> sparkSpikeConf;
    //kafka配置
    private SparkKafkaConf<KafkaConsumerConf, KafkaProducerConf> sparkKafkaConf;
    //redis配置
    private SparkRedisConf<RedisConf, RedisConf> sparkRedisConf;
    //redis Conf
    private RedisConf redisConf;
    //通过主动获取的方式获得消息的消息生成者Conf
    private FlowRequesterConf requesterConf;

    //获取数据持续的时间
    private int durationsSeconds = 5;
    //执行器类
    private String executorClass = "";

    /**
     * 深复制一个对象
     * <li>默认对象是单实例的，如果有地方修改它将反馈到所有使用点。</li>
     *
     * @return SparkExecutorConf
     */
    public SparkExecutorConf deepClone() {
        SparkExecutorConf conf = new SparkExecutorConf();
        try {
            BeanUtils.copyProperties(conf, this);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        return conf;
    }
}

